/*
实验2 寻找圆周率公式的加强版
Π/2≈(2/1)×(2/3)×(4/3)×(4/5)×(6/5)×(6/7)×...
用前100项之积计算圆周率pi
*/
#include <stdio.h>
int main(){
    //0.确定求解办法
    //Π/2≈(2×2)/(1×3)×(4×4/3×5)×...
    //term1 = (2×2)/(2-1)×(2+1)
    //term2 = (4×4)/((4-1)×(4+1))
    //term = (i×i)/((i-1)×(i+1))
    //1.确定所需变量的个数
    //pi,term,pi=2*term,
    //i循环变量,i=2,i+=2
    int i;
    float term,pi=1.0f;
    for(i=2;i<=100;i+=2){
        term = (float)(i*i)/((i-1)*(i+1));
        pi = pi*term;
    }
    printf("pi=%f",2*pi);
    return 0;
}